package com.xinpu.service;


import com.xinpu.exception.AuthException;
import com.xinpu.shiro.Loginer;
import org.apache.shiro.SecurityUtils;

public class OwnService {

    /**
     * 获取当前登录的用户
     *
     * @return
     */
    public static Integer getCurrentUserID() {
        Loginer loginer = ((Loginer) SecurityUtils.getSubject().getPrincipal());
        if (loginer == null) {
            throw new AuthException("用户未登录");
        }
        return loginer.getId();
    }

    public static Loginer getLoginer() {
        Loginer loginer = ((Loginer) SecurityUtils.getSubject().getPrincipal());
        return loginer;
    }
}
